#ifndef __TASKQUEUE_H_
#define __TASKQUEUE_H_

#include "Noncopyable.hpp"
#include "MutexLock.hpp"
#include "Condition.hpp"
#include <queue>
#include <functional>

using std::queue;

namespace ln{

using ElemType = std::function<void()>;

class TaskQueue
:Noncopyable
{
public:
    TaskQueue(size_t);
    ~TaskQueue();
    bool empty() const;
    bool full() const;
    void push(ElemType &&);
    ElemType pop();
    void wakeup();

private:
    queue<ElemType> _taskque;
    size_t _queSize;
    MutexLock _mutex;
    Condition _notEmpty;
    Condition _notFull;
    bool _flag;
};

}//end of namespace ln


#endif

